package com.visionet.jumper.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;

import com.visionet.jumper.core.domain.bean.Page;
import com.visionet.jumper.core.domain.search.Searchable;
import com.visionet.jumper.core.repository.BaseRepository;
import com.visionet.jumper.core.service.BaseService;

public abstract class AbstractBaseService<M> implements BaseService<M, String> {
	
	protected BaseRepository<M> baseRepository;

	@Override
	@Autowired
	public void setBaseRepository(BaseRepository<M> baseRepository) {
		this.baseRepository = baseRepository;
	}
	
	@Override
	public M save(M m) {
		return baseRepository.save(m);
	}
	
	@Override
	public long count(Searchable searchable) {
		return baseRepository.count(searchable);
	}

	@Override
	public long count() {
		return baseRepository.count();
	}

	@Override
	public boolean exist(String id) {
		return baseRepository.exists(id);
	}

	@Override
	public void delete(String id) {
		baseRepository.delete(id);
	}

	@Override
	public void delete(M m) {
		baseRepository.delete(m);
	}

	@Override
	public M findOne(String id) {
		return baseRepository.findOne(id);
	}

	@Override
	public List<M> findAll() {
		return baseRepository.findAll();
	}

	@Override
	public List<M> findAll(Sort sort) {
		return baseRepository.findAll(sort);
	}

	@Override
	public Page findAllForPage(Searchable searchable) {
		return baseRepository.findAllForPage(searchable);
	}

	@Override
	public List<M> findAll(Searchable searchable) {
		return baseRepository.findAll(searchable);
	}

}
